package com.hspedu.newData.dmsxl.贪心算法.easy;

import org.junit.Test;

import java.util.Arrays;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-26 
 * @Version: 1.0
 */

public class LC455分发饼干 {

    public int findContentChildren(int[] g, int[] s) {

        Arrays.sort(g);
        Arrays.sort(s);

        int count = 0;
        for (int i = g.length - 1; i >= 0; i--) {
            int j = s.length - count - 1;
            if (j >= 0 && g[i] <= s[j]){
                count++;
            }
        }
        return count;

    }


    @Test
    public void test() {
        // 测试代码
//        int contentChildren = findContentChildren(new int[]{1, 2, 3}, new int[]{1, 1});
        int contentChildren1 = findContentChildren(new int[]{10,9,8,7}, new int[]{10,9,8,7});
        System.out.println("=====");
    }
}
